package test01.Result;

public class CodeMsg {
    private int code;
    private String msg;

    public static CodeMsg VALID_ERROR=new CodeMsg(10001,"参数错误：%s");

    public static CodeMsg SERVICE_ERROR=new CodeMsg(10002,"意外错误");

    public static CodeMsg GLOBAL_SERVICE_ERROR=new CodeMsg(10003,"自定义全局错误");



    public CodeMsg fillArgs(Object... args){
        int code=this.code;
        String msg=String.format(this.msg,args);
        return new CodeMsg(code,msg);

    }
    public CodeMsg(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
